setClass("ReduceClustListComputer",contains="VListComputer",
		representation(
				.clusterizer="VClusterAlg"
		),
		prototype=prototype(
				.description="Reduce and Cluster List Computer class"
		
		)
)   
#generic methods
setGeneric("changeClusterAlg",function(.Object,clusterizer,...){standardGeneric("changeClusterAlg")})
#methods
setMethod("initialize",
		signature="ReduceClustListComputer",
		function(.Object,reducer,clusterizer,...){
			.Object <-callNextMethod(.Object,reducer,...)
			.Object@.clusterizer <- clusterizer
			return(.Object)
		})

setMethod("changeClusterAlg",
		signature="ReduceClustListComputer",
		function(.Object,clusterizer,...){
			.Object@.clusterizer <- clusterizer
			return(.Object)
		})


setMethod("get_description",
		signature="ReduceClustListComputer",
		definition=function(.Object){
			dsc <-paste(get_description(.Object@.reducer), get_description(.Object@.clusterizer), sep=" ")
			return(dsc)
		})



setMethod("computeList",
		signature="ReduceClustListComputer",
		definition=function(.Object,inputSet,...){
			#check input set
			callNextMethod(.Object,inputSet,...)
			#reduce
			 reduced <-getSavedSet(.Object@.reducer)
			if(is.null(reduced)){
				reduced <- reduce(.Object@.reducer,inputSet$X)
			}
			inputSet$X <-reduced
			#check illegal values
			containsNas(.Object,inputSet)
			#clusterize
			clusters <-clusterize(.Object@.clusterizer,inputSet)
			#add new slot for inputSet
			inputSet[["clusters"]] <-clusters
			return(inputSet)
			
			
			
		}
) 
